package cn.ncupyh.polymorphism;

public class Person {
    /*3.定义Person类//饲养员
    属性:姓名，年龄
    行为: keepPet(Dog dog,String something)方法功能: 喂养宠物狗，something表示喂养的东西
    行为: keepPet(Cat cat,String something)方法功能: 喂养宠物猫，something表示喂养的东西生成空参有参构造，set和get方法*/
    public String name;
    public int age;
    public void keepPet(Dog dog,String something){
//        System.out.println("喂养宠物狗" + something);
        System.out.println("年龄为" + age +"岁的"+name+"养了一只"+ dog.color +"的"+ dog.age+"岁的狗");
        dog.eat(something);
    }

    public void keepPet(Cat cat,String something){
//        System.out.println("喂养宠物猫" + something);
        System.out.println("年龄为"+age+"岁的"+name+"养了一只"+cat.color+"的"+cat.age+"岁的猫");
        cat.eat(something);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public Person() {
    }
}
